package com.corpdata.app.statistical.dao;

import java.util.List;
import java.util.Map;

import org.apache.ibatis.annotations.Select;

import com.corpdata.app.statistical.entity.EChartCarrier;

public interface StatisticalMapper {

	/**
	 * 	查询会议室每天的使用率
	 * 	使用率：每天使用过会议室的个数/总会议室的个数，且同一个会议室使用多次只算一次
	 * @param params 起始时间结束时间 以天为最小精度
	 * @return
	 */
	@Select("<script>select count(1) into @allcount from project_field; " + 
			"select count(1)/@allcount y,bsd x from  " + 
			"( " + 
			"select count(1) count,DATE_FORMAT(Book_Start_Date,'%Y/%m/%d') bsd  " + 
			"from project_field_team where 1=1 "+
			"<if test='staDate!=null and endDate!=null ' >and Book_Start_Date &gt;= #{staDate} and Book_Start_Date &lt;= #{endDate} </if>"+
			"<if test='projectId!=null' >and Fk_project=#{projectId} </if>"+
			"GROUP BY Fk_field,bsd ORDER BY bsd desc " + 
			") t GROUP BY bsd</script>")
	List<EChartCarrier> selectRoomUsageRate(Map<String, Object> params);
	
}
